<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\logic;

/**
 * 个人逻辑
 */
class Resume extends AdminBase
{

    /**
     * 简历列表
     */
    public function getResumeList($where = [], $field = true, $order = '', $paginate = 0)
    {

        return $this->modelResume->getList($where, $field, $order, $paginate);
    }

    /**
     * 简历编辑
     */
    public function resumeEdit($data = [])
    {
        sf($data);
        $validate_result = $this->validateResume->scene('edit')->check($data);

        if (!$validate_result) {

            return [RESULT_ERROR, $this->validateResume->getError()];
        }

        $url = url('resumeList');

        $result = $this->modelResume->setInfo($data);

        $handle_text = empty($data['id']) ? '新增' : '编辑';

        $result && action_log($handle_text, '个人' . $handle_text . '，name：' . $data['nickname']);

        return $result ? [RESULT_SUCCESS, '操作成功', $url] : [RESULT_ERROR, $this->modelResume->getError()];
    }

    /**
     * 获取简历信息
     */
    public function getResumeInfo($where = [], $field = true)
    {

        return $this->modelResume->getInfo($where, $field);
    }

    /**
     * 简历删除
     */
    public function resumeDel($where = [])
    {

        $result = $this->modelResume->deleteInfo($where);

        $result && action_log('删除', '个人信息删除' . '，where：' . http_build_query($where));

        return $result ? [RESULT_SUCCESS, '删除成功'] : [RESULT_ERROR, $this->modelBlogroll->getError()];
    }
}
